{% extends 'admin/index.html' %}

{% block member %}
<div class="is-block">
    <div class=" is-pulled-left">
        <h1 class=" is-size-4">
            <span class="icon">
                <i class="mdi mdi-image-multiple"></i>
            </span>
            Banner管理
        </h1>
    </div>

    {% block button %}
    <div class=" is-pulled-right">
        <a href="{{ url_for('admin.banner_add') }}" class=" button is-primary is-light">
            <span class="icon"><i class="mdi mdi-plus-thick"></i></span>
            <span>添加轮播图</span>
        </a>
    </div>
    {% endblock button %}
    <div class="is-clearfix"></div>
    <div class=" dropdown-divider"></div>

    <!-- 消息闪现 -->
    {% with messages = get_flashed_messages() %}
    <b-message type="is-success">
      {% if messages %}
      <ul class=flashes>
        {% for message in messages %}
        <li>{{ message }}</li>
        {% endfor %}
      </ul>
      {% endif %}
    </b-message>
    {% endwith %}
    <!-- 表单验证 -->
    {% if form and form.errors %}
    <b-message type="is-danger">
    <ul class="errors">
        {% for error, v in form.errors.items() %}
            <li>{{ error }}：{{ v[0] }}</li>
        {% endfor %}
    </ul>
    </b-message>
    {% endif %}
</div>

{% block table_content %}
<div class="table-container">
    <table class="table is-fullwidth is-hoverable is-striped">
        <thead>
            <tr>
              <th>ID</th>
              <th>轮播图</th>
              <th>Url</th>
              <th>描述</th>
              <th>发布日期</th>
              <th>操作</th>
            </tr>
        </thead>
        <tbody>

            {% for banner in banners %}
            <tr>
                <td>{{ banner.id }}</td>
                <td>
                    <figure class="image is-16by9">
                        <img src="/admin/static/{{ banner.img }}">
                    </figure>
                </td>
                <td>{{ banner.url }}</td>
                <td>{{ banner.desc }}</td>
                <td>{{ banner.add_date }}</td>
                <td>
                    <div class="tags">
                        <a href="{{ url_for('admin.banner_edit', banner_id=banner.id) }}" class="tag is-success is-light">
                            <span class="icon">
                                <i class="mdi mdi-square-edit-outline"></i>
                            </span>
                            编辑
                        </a>
                        <a href="{{ url_for('admin.banner_del', banner_id=banner.id) }}" class="tag is-danger is-light">
                            <span class="icon">
                                <i class="mdi mdi-trash-can-outline"></i>
                            </span>
                            删除
                        </a>
                    </div>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>

{% endblock table_content %}
{% endblock member %}